package com.hongmeng.web.controller.operater.operaterUser;

import java.util.List;

import com.hongmeng.operater.domain.operaterUser.HmDoctor;
import com.hongmeng.operater.service.operaterUser.IHmDoctorService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hongmeng.common.annotation.Log;
import com.hongmeng.common.core.controller.BaseController;
import com.hongmeng.common.core.domain.AjaxResult;
import com.hongmeng.common.enums.BusinessType;
import com.hongmeng.common.utils.poi.ExcelUtil;
import com.hongmeng.common.core.page.TableDataInfo;

/**
 * 医生信息Controller
 * 
 * @author hongmeng
 * @date 2021-03-02
 */
@RestController
@RequestMapping("/operater/doctor")
public class HmDoctorController extends BaseController
{
    @Autowired
    private IHmDoctorService hmDoctorService;

    /**
     * 查询医生信息列表
     */
    @PreAuthorize("@ss.hasPermi('operater:doctor:list')")
    @GetMapping("/list")
    public TableDataInfo list(HmDoctor hmDoctor)
    {
        startPage();
        List<HmDoctor> list = hmDoctorService.selectHmDoctorList(hmDoctor);
        return getDataTable(list);
    }

    /**
     * 导出医生信息列表
     */
    @PreAuthorize("@ss.hasPermi('operater:doctor:export')")
    @Log(title = "医生信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HmDoctor hmDoctor)
    {
        List<HmDoctor> list = hmDoctorService.selectHmDoctorList(hmDoctor);
        ExcelUtil<HmDoctor> util = new ExcelUtil<HmDoctor>(HmDoctor.class);
        return util.exportExcel(list, "doctor");
    }

    /**
     * 获取医生信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('operater:doctor:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(hmDoctorService.selectHmDoctorById(id));
    }

    /**
     * 新增医生信息
     */
    @PreAuthorize("@ss.hasPermi('operater:doctor:add')")
    @Log(title = "医生信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HmDoctor hmDoctor)
    {
        return toAjax(hmDoctorService.insertHmDoctor(hmDoctor));
    }

    /**
     * 修改医生信息
     */
    @PreAuthorize("@ss.hasPermi('operater:doctor:edit')")
    @Log(title = "医生信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HmDoctor hmDoctor)
    {
        return toAjax(hmDoctorService.updateHmDoctor(hmDoctor));
    }

    /**
     * 删除医生信息
     */
    @PreAuthorize("@ss.hasPermi('operater:doctor:remove')")
    @Log(title = "医生信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(hmDoctorService.deleteHmDoctorByIds(ids));
    }
}
